package cn.webrx;

public class Str6 {
    public static void main(String[] args) {
        String str = "    hello   java          ";
        System.out.println(str);

        //清除字符串左边 右边连续的空格
        System.out.println(str.trim());

        //清除所有空格
        System.out.println(str.replace(" ",""));

        //格式化方法
        int age = 18;
        String name = "李四";
        String s = String.format("姓名：%s，年龄：%d岁。",name,age);
        System.out.println(s);


        System.out.println("    java 1.8    ");
        //和trim（）方法，清除左边 右边连续的空格
        System.out.println("    java 1.8    ".strip());
        System.out.println("    java 1.8    ".stripLeading());//清除左右
        System.out.println("    java 1.8    ".stripTrailing());//清除右边

        System.out.println("            hello".stripIndent());
        System.out.println("            hello".trim());


        System.out.println("".isBlank());//true
        System.out.println("".isEmpty());//true

         System.out.println("123".isBlank());//false
        System.out.println("123".isEmpty());//false

         System.out.println(" ".isBlank());//true
        System.out.println(" ".isEmpty());//false
    }
}
